<form nz-form [formGroup]="edittionForm">

  <!-- 版本名称 -->
  <nz-form-item>
    <nz-form-label nzRequired nzFor="displayName">版本名称</nz-form-label>
    <nz-form-control>
      <input nz-input placeholder="版本名称" [(ngModel)]="edition.displayName" formControlName="displayName" maxlength="64">
      <nz-form-explain *ngIf="edittionForm.get('displayName').dirty && edittionForm.get('displayName').errors">
        <ng-container *ngIf="edittionForm.get('displayName').errors['required']">此项为必填项！</ng-container>
        <ng-container *ngIf="edittionForm.get('displayName').errors['maxLength']">版本名称最大长度不得超过64个字符！</ng-container>
      </nz-form-explain>
    </nz-form-control>
  </nz-form-item>

  <!-- 订阅版本 -->
  <nz-form-item>
    <nz-form-label nzRequired nzFor="subscriptionVersion">订阅版本</nz-form-label>
    <nz-form-control>
      <nz-radio-group [(ngModel)]="subscriptionVersion" formControlName="subscriptionVersion">
        <label nz-radio nzValue="FreeVersion">免费版</label>
        <label nz-radio nzValue="ChargedVersion">收费版</label>
      </nz-radio-group>
    </nz-form-control>
  </nz-form-item>

  <!-- 收费版 -->
  <div *ngIf="subscriptionVersion=='ChargedVersion'">
    <!-- 每月价格 -->
    <nz-form-item>
      <nz-form-label nzFor="monthlyPrice">每月价格</nz-form-label>
      <nz-form-control>
        <nz-input-group nzCompact class="input-group">
          <nz-select [(ngModel)]="currency" formControlName="currency">
            <nz-option [nzLabel]="'￥'" [nzValue]="'￥'"></nz-option>
          </nz-select>
          <input nz-input placeholder="每月价格" formControlName="monthlyPrice" [(ngModel)]="edition.monthlyPrice">
        </nz-input-group>
      </nz-form-control>
    </nz-form-item>

    <!-- 年度价格 -->
    <nz-form-item>
      <nz-form-label nzFor="annualPrice">年度价格</nz-form-label>
      <nz-form-control>
        <nz-input-group nzCompact class="input-group">
          <nz-select [(ngModel)]="currency" formControlName="currency">
            <nz-option [nzLabel]="'￥'" [nzValue]="'￥'"></nz-option>
          </nz-select>
          <input nz-input placeholder="年度价格" formControlName="annualPrice" [(ngModel)]="edition.annualPrice">
        </nz-input-group>
      </nz-form-control>
    </nz-form-item>

    <!-- 是否试验激活 -->
    <div nz-col nzSpan="24">
      <div nz-row>
        <div class="checkbox-div" nz-col nzSpan="12">
          <label nz-checkbox formControlName="isTrialActive" [(ngModel)]="isTrialActive">是否试验激活</label>
        </div>
      </div>
    </div>

    <!-- 试验天数 -->
    <nz-form-item *ngIf="isTrialActive">
      <nz-form-label nzFor="trialDayCount">试验天数</nz-form-label>
      <nz-form-control>
        <input nz-input type="number" placeholder="试验天数" [(ngModel)]="edition.trialDayCount" formControlName="trialDayCount">
      </nz-form-control>
    </nz-form-item>

    <!-- 订阅过期等待 -->
    <div nz-col nzSpan="24">
      <div nz-row>
        <div class="checkbox-div" nz-col nzSpan="12">
          <label nz-checkbox formControlName="isWaitingDayActive" [(ngModel)]="isWaitingDayActive">订阅过期等待</label>
        </div>
      </div>
    </div>

    <!-- 过期等待天数 -->
    <nz-form-item *ngIf="isWaitingDayActive">
      <nz-form-label nzFor="waitingDayAfterExpire">过期等待天数</nz-form-label>
      <nz-form-control>
        <input nz-input type="number" placeholder="过期等待天数" [(ngModel)]="edition.waitingDayAfterExpire" formControlName="waitingDayAfterExpire">
      </nz-form-control>
    </nz-form-item>

    <!-- 订阅过期操作 -->
    <nz-form-item>
      <nz-form-label nzFor="expireOperate">订阅过期操作</nz-form-label>
      <nz-form-control>
        <nz-radio-group [(ngModel)]="expireOperate" formControlName="expireOperate" (ngModelChange)="expireOperateFocus()">
          <label nz-radio nzValue="Disable">停用租客</label>
          <label nz-radio nzValue="AssignVersion">分配其他版本</label>
        </nz-radio-group>
      </nz-form-control>
    </nz-form-item>

    <!-- 版本 -->
    <nz-form-item *ngIf="isAssignVersion">
      <nz-form-label>版本</nz-form-label>
      <nz-form-control nzHasFeedback>
        <edition-combo [editionId]="edition.expiringEditionId" (selectedEditionChange)="selectedEditionChange($event)"
          [placeholder]="'请选择'" [addAllItem]="'false'" [addNotAssignedItem]="'false'"></edition-combo>
      </nz-form-control>
    </nz-form-item>

  </div>


</form>

<div class="drawer_footer">
  <button type="button" (click)="close()" class="ant-btn" style="margin-right: 8px;"><span>取消</span></button>
  <button nz-button type="button" class="ant-btn ant-btn-primary" (click)="submitForm()" [nzLoading]="isLoadingBtn"><span>提交</span></button>
</div>